﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Project.Master
{
    public partial class Checktime : System.Web.UI.Page
    {
        string Connection = ConfigurationManager.ConnectionStrings["DB_UdrinkConnectionString"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
            InsertTime();
        }
        private void BindingGrid()
        {
            DataTable dt = GetData();
            Gv_ShowEmpcheck.DataSource = dt;
            Gv_ShowEmpcheck.DataBind();
        }

        private DataTable GetData()
        {
            string sqltext = @"SELECT TB_Employee.Employee_ID,TB_Employee.FirstName,TB_Employee.LastName,TB_Time_Cards.Check_in,TB_Department.Department_Name,
                                TB_Time_Cards.Check_out,TB_Time_Cards.Emp_QRcode from TB_Employee
                                INNER JOIN TB_Time_Cards ON TB_Employee.Employee_ID = TB_Time_Cards.Employee_ID
                                INNER JOIN TB_Department ON TB_Employee.Departmernt_ID = TB_Department.Department_ID";
            SqlConnection sqlconn = new SqlConnection(Connection);
            SqlDataAdapter da = new SqlDataAdapter(sqltext, sqlconn);
            DataSet ds = new DataSet();
            da.Fill(ds);

            return ds.Tables[0];

        }
        private void InsertTime()
        {
            Data DataTime = new Data();

            DataTime.Emp_ID = Session["IDEmp"].ToString();
            DataTime.Check_in = DateTime.Now;

           InsertData InsertDataTime = new InsertData();
            InsertDataTime.InsertsTime(DataTime);
            
            BindingGrid();
            
            
        }
    }
}